package cn.hua.trip.base.service.impl;

import cn.hua.trip.base.domain.Region;
import cn.hua.trip.base.mapper.RegionMapper;
import cn.hua.trip.base.query.QueryObject;
import cn.hua.trip.base.query.RegionQueryObject;
import cn.hua.trip.base.query.StrategyQueryObject;
import cn.hua.trip.base.service.IRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegionServiceImpl implements IRegionService{
    @Autowired
    private RegionMapper regionMapper;

    @Override
    public List<Region> list() {
        return regionMapper.selectAll();
    }

    @Override
    public List<Region> selectByState(QueryObject qo) {
        return regionMapper.selectByState(qo);
    }

    @Override
    public void saveOrUpdate(Region region) {
        if (region.getId()==null){
            regionMapper.insert(region);
        }else{
            regionMapper.updateByPrimaryKey(region);
        }
    }

    @Override
    public List<Region> selectByParentId(Long  parentId) {
        List<Region> list = regionMapper.selectByParentId(parentId);
        return list;
    }
}
